package com.lovetemperature.action;

import java.util.Date;

import com.lovetemperature.model.Order;
import com.lovetemperature.model.SaleRec;
import com.lovetemperature.service.OrderService;
import com.lovetemperature.service.SaleRecService;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class OneOrderAction extends ActionSupport{
	private OrderService orderService;
	private SaleRecService saleRecService;
	private Order order;
	private String orderNum;
	
	private String showCategory="订单管理";
	
	public String show() {
		order = orderService.findById(new Long(orderNum));
		ActionContext.getContext().put("order", order);
		return "success";
	}
	
	public String submit(){
		orderService.update(order);
		return "success";
	}
	
	public String finish(){
		order = orderService.findById(new Long(orderNum));
		SaleRec saleRec = new SaleRec();
		saleRec.setFinishDate(new Date());
		saleRec.setOrder(order);
		saleRec.setShop(order.getShop());
		saleRecService.addSaleRec(saleRec);
		
		order.setFinished(true);
		orderService.update(order);
		return "success";
	}

	public OrderService getOrderService() {
		return orderService;
	}

	public void setOrderService(OrderService orderService) {
		this.orderService = orderService;
	}

	public Order getOrder() {
		return order;
	}

	public void setOrder(Order order) {
		this.order = order;
	}

	public String getOrderNum() {
		return orderNum;
	}

	public void setOrderNum(String orderNum) {
		this.orderNum = orderNum;
	}

	public String getShowCategory() {
		return showCategory;
	}

	public void setShowCategory(String showCategory) {
		this.showCategory = showCategory;
	}

	public SaleRecService getSaleRecService() {
		return saleRecService;
	}

	public void setSaleRecService(SaleRecService saleRecService) {
		this.saleRecService = saleRecService;
	}
}
